﻿// Logger.h: 标准系统包含文件的包含文件
// 或项目特定的包含文件。
#pragma once

#include "CfgRead.h"

class Logger {
public:
	Logger();

    static Logger* GetInstance();
    void Init();
    template<typename... Args>
    void LogPrint(std::string type, int level, const QString& fmt, Args&&...args)
    {
        QStringList list;
        int arr[] = { (AddString(list, args), 0)... };
        CacheLogString(type, level, fmt, list);
    }
private:
    void ClearHistory();
    void LoadLoggerModule();
    void CacheLogString(std::string type, int level, const QString& str, QStringList& args);

    QString FileName(QString file);
    void log(int level, std::string type, std::string log);

    template<class T>
    void AddString(QStringList& list, T arg)
    {
        std::ostringstream oss;
        oss << arg;
        std::string str = oss.str();
        list.append(QString::fromStdString(str));
    }
    void AddString(QStringList& list, QString arg);
    void AddString(QStringList& list, QByteArray arg);


private:
    LogSet m_set = {};
    
};
